<?php
$content = '';
if (!empty($options)){
	$fn_zen_href_link_parameters1 = (isset($_GET['cPath'])?'cPath='.$_GET['cPath'].'&':'').(isset($_GET['options_values_id'])?'options_values_id='.$_GET['options_values_id'].'_':'options_values_id='); 
	$fn_zen_href_link_parameters2 = (isset($_GET['cPath'])?'cPath='.$_GET['cPath'].'&':'');
	$_GET_options_values_id = array_unique(array_map('zen_string_to_int',explode('_',$_GET['options_values_id'])));
	$content_group_choosed = '';
	$the_options_values_choosed = array();
	foreach ($options as $products_options_id=>$products_options_values){
		//判断是当前选项是否有被选择
		$intersect = array_intersect(array_keys($products_options_values),$_GET_options_values_id);
		if (empty($intersect)){
			$content .= '<div class="options_group"><div class="options_group_header">▼Shop BY '.current(current($products_options_values)).'</div><div class="options_group_body">';
			foreach ($products_options_values as $products_options_values_id=>$option_info){
				$content .= '<div><a href="'.zen_href_link(FILENAME_DEFAULT,$fn_zen_href_link_parameters1.$products_options_values_id).'">'.$option_info['products_options_values_name'].'</a></div>';
			}
			$content .= '</div></div>';
		}else {
			$content_group_choosed .= '<div class="options_group_choosed"><div class="options_group_header">▼Shop BY '.current(current($products_options_values)).'</div><div class="options_group_body">';
			foreach ($intersect as $products_options_id){
				$str = implode('_',array_diff ($_GET_options_values_id,array($products_options_id)));
				$str = empty($str)?'':'options_values_id='.$str;
				$the_options_values_choosed[] = array('products_options_values_id'=>$products_options_id,'products_options_name'=>$products_options_values[$products_options_id]['products_options_values_name']);
				$content_group_choosed .= '<div><a href="'.zen_href_link(FILENAME_DEFAULT,$fn_zen_href_link_parameters2.$str).'">'.$products_options_values[$products_options_id]['products_options_values_name'].'</a></div>';
			}
			$content_group_choosed .= '</div></div>';
		}		
		
	}
	$content = '<div class="refine_by_container"><div class="refine_by_container_header">REFINE BY'.(empty($_GET['options_values_id'])?'':'<a style="float:right;font-weight:normal" href="'.zen_href_link(FILENAME_DEFAULT,'cPath='.$_GET['cPath'],true).'">clear all</a>').'</div>'.$content_group_choosed.$content.'</div>';
}

echo $content;